﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GastosDelHogar
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

        }

        private void CargarGraficaDeGastos()
        {
            Controles.usrChartControl usrControl = new Controles.usrChartControl();
            this.cntMain.Content = usrControl;
        }

        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

        }

        private void btnIngreso_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            vsErrores.Errors.Add(new ValidationSummaryItem("revento para la mierda"));
        }

       

        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            CargarGraficaDeGastos();
        }



        private void btnConcepto_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Controles.ctrlCargarConcepto ctrlConcepto = new Controles.ctrlCargarConcepto();
            ctrlConcepto.OnCerrarVentaConcepto += new GastosDelHogar.Controles.ctrlCargarConcepto.CerrarVentanaConceptoDelegate(ctrlConcepto_OnCerrarVentaConcepto);
            ctrlConcepto.OnErrorSubscribed += new GastosDelHogar.Controles.ctrlCargarConcepto.ErrorSummaryConceptoDelegate(ctrlConcepto_OnErrorSubscribed);
            this.cntMain.Content = ctrlConcepto;
        }

        void ctrlConcepto_OnCerrarVentaConcepto(Control control)
        {
            this.cntMain.Content =(Control)control;
        }

        void ctrlConcepto_OnErrorSubscribed(string error)
        {
            vsErrores.Errors.Clear();
            vsErrores.Errors.Add(new ValidationSummaryItem(error));
        }
    }
}
